package task;

import java.util.Scanner;

public class Task5_2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("塔层数");
        int n = input.nextInt();
        //System.out.println(hanoi(n));
        char a = 'A';
        char b = 'B';
        char c = 'C';
        hanoi(a,b,c,n);

    }
    public static void hanoi(char a,char b,char c,int n){
        if(n == 1 ){
            System.out.println(a + " → " +  c);
        }else{
            hanoi(a,c,b,n-1);//a上的n-1层通过b放到c
            System.out.println(a + " → " + c);
            //System.out.println(a + "→" + c);
            hanoi(b,a,c,n -1);//再将b上的n-1层通过a放到c

        }
        /**
         * 将除最后一层大的移到中间 再将最后大的移到第三个
         * 最后将剩下的n-1层移到第三个
         */



        //return hanoi(n - 1) + 1 + hanoi(n - 1) ;//次数
    }
}
